<template>
	<view>
		<!-- 店列表 -->
		<view class="takeOut-near" v-for="item in takeOutRows">
			<view class="takeOut-near-item"  @click="goDetails" :data-id="item.id">
				<view class="near-item-img">
					<image :src="getImg(item.imgUrl)" mode="scaleToFill"></image>
				</view>
				<view class="near-item-text">
					<h2>{{item.name}}</h2>
					<view class="item-text-content">
						<view>
							<p>{{item.score}}分</p>
							<p>人均: {{item.avgCost}}</p>
							<p>月销: {{item.saleQuantity}}</p>
						</view>
						<view>
							<p>距离: {{item.distance}}m</p>
							<p>配送时间: {{item.deliveryTime}}分</p>
						</view>
					</view>
				</view>
			</view>
			<!-- 菜列表 -->
			<view class="dish-name" v-for="x in item.productList" v-if="isDishName">
				<view class="dish-name-img">
					<image :src="getImg(x.imgUrl)" mode="widthFix"></image>
				</view>
				<view class="dish-name-text">
					<p>{{x.name}}</p>
					<p>¥{{x.price}}</p>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		getImg
	} from '../../utils/request'
	export default {
		name: "takeOutList",
		props: ["takeOutRows", "isDishName", "goDetailsUrl"],
		data() {
			return {
				getImg: getImg
			}
		},
		created() {

		},
		methods: {
			goDetails(e) {
				uni.navigateTo({
					url: this.goDetailsUrl + e.currentTarget.dataset.id
				})
			}
		}
	}
</script>

<style scoped>
	/* 附近店家列表 */
	.takeOut-near {
		display: flex;
		flex-direction: column;
		margin-bottom: 55px;
	}



	.takeOut-near>*+* {
		margin-top: .5em;
	}
	/* 店列表 */
	.takeOut-near-item {
		display: flex;
		width: 90%;
		margin-left: 5%;
	}

	.takeOut-near-item>*+* {
		margin-left: 2%;
	}

	.takeOut-near-item>.near-item-img {
		width: 30%;
		height: 80px;
	}

	.takeOut-near-item>.near-item-img>image {
		width: 100%;
		height: 80px;
	}

	.takeOut-near-item>.near-item-text {
		display: flex;
		flex-direction: column;
		width: 68%;
		font-size: .8em;
	}

	.takeOut-near-item>.near-item-text>.item-text-content {
		display: flex;
		justify-content: space-between;
	}

	.item-text-content>*+* {
		margin-top: .5em;
	}
	/* 菜列表 */
	.dish-name {
		display: flex;
		justify-content: space-between;
		width: 90%;
		margin-left: 5%;
	}
	.dish-name>.dish-name-img {
		width: 30%;
	}
	
	.dish-name>.dish-name-img>image {
		width: 100%;
	}
</style>
